// --------------------------------------------------------------------------------------------
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
// 
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
// 
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
// 
// <remarks>
// Generated by IDLImporter from file nsIParserUtils.idl
// 
// You should use these interfaces when you access the COM objects defined in the mentioned
// IDL/IDH file.
// </remarks>
// --------------------------------------------------------------------------------------------
namespace Gecko
{
	using System;
	using System.Runtime.InteropServices;
	using System.Runtime.InteropServices.ComTypes;
	using System.Runtime.CompilerServices;
	
	
	/// <summary>
    /// Non-Web HTML parser functionality to Firefox extensions and XULRunner apps.
    /// Don't use this from within Gecko--use nsContentUtils, nsTreeSanitizer, etc.
    /// directly instead.
    /// </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("a1101145-0025-411e-8873-fdf57bf28128")]
	public interface nsIParserUtils
	{
		
		/// <summary>
        /// Parses a string into an HTML document, sanitizes the document and
        /// returns the result serialized to a string.
        ///
        /// The sanitizer is designed to protect against XSS when sanitized content
        /// is inserted into a different-origin context without an iframe-equivalent
        /// sandboxing mechanism.
        ///
        /// By default, the sanitizer doesn't try to avoid leaking information that
        /// the content was viewed to third parties. That is, by default, e.g.
        /// <img src> pointing to an HTTP server potentially controlled by a third
        /// party is not removed. To avoid ambient information leakage upon loading
        /// the sanitized content, use the SanitizerInternalEmbedsOnly flag. In that
        /// case, <a href> links (and similar) to other content are preserved, so an
        /// explicit user action (following a link) after the content has been loaded
        /// can still leak information.
        ///
        /// By default, non-dangerous non-CSS presentational HTML elements and
        /// attributes or forms are not removed. To remove these, use
        /// SanitizerDropNonCSSPresentation and/or SanitizerDropForms.
        ///
        /// By default, comments and CSS is removed. To preserve comments, use
        /// SanitizerAllowComments. To preserve <style> and style="", use
        /// SanitizerAllowStyle. -moz-binding is removed from <style> and style="" if
        /// present. In this case, properties that Gecko doesn't recognize can get
        /// removed as a side effect. Note! If -moz-binding is not present, <style>
        /// and style="" and SanitizerAllowStyle is specified, the sanitized content
        /// may still be XSS dangerous if loaded into a non-Gecko Web engine!
        ///
        /// @param src the HTML source to parse (C++ callers are allowed but not
        /// required to use the same string for the return value.)
        /// @param flags sanitization option flags defined above
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Sanitize([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase src, uint flags, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase retval);
		
		/// <summary>
        /// Convert HTML to plain text.
        ///
        /// @param src the HTML source to parse (C++ callers are allowed but not
        /// required to use the same string for the return value.)
        /// @param flags conversion option flags defined in nsIDocumentEncoder
        /// @param wrapCol number of characters per line; 0 for no auto-wrapping
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void ConvertToPlainText([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase src, uint flags, uint wrapCol, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase retval);
		
		/// <summary>
        /// Parses markup into a sanitized document fragment.
        ///
        /// @param fragment the input markup
        /// @param flags sanitization option flags defined above
        /// @param isXML true if |fragment| is XML and false if HTML
        /// @param baseURI the base URL for this fragment
        /// @param element the context node for the fragment parsing algorithm
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsIDOMDocumentFragment ParseFragment([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Gecko.CustomMarshalers.AStringMarshaler")] nsAStringBase fragment, uint flags, [MarshalAs(UnmanagedType.U1)] bool isXML, [MarshalAs(UnmanagedType.Interface)] nsIURI baseURI, [MarshalAs(UnmanagedType.Interface)] nsIDOMElement element);
	}
	
	/// <summary>nsIParserUtilsConsts </summary>
	public class nsIParserUtilsConsts
	{
		
		// <summary>
        // Flag for sanitizer: Allow comment nodes.
        // </summary>
		public const ulong SanitizerAllowComments = (1<<0);
		
		// <summary>
        // Flag for sanitizer: Allow <style> and style="" (with contents sanitized
        // in case of -moz-binding). Note! If -moz-binding is absent, properties
        // that might be XSS risks in other Web engines are preserved!
        // </summary>
		public const ulong SanitizerAllowStyle = (1<<1);
		
		// <summary>
        // Flag for sanitizer: Only allow cid: URLs for embedded content.
        //
        // At present, sanitizing CSS backgrounds, etc., is not supported, so setting
        // this together with SanitizerAllowStyle doesn't make sense.
        //
        // At present, sanitizing CSS syntax in SVG presentational attributes is not
        // supported, so this option flattens out SVG.
        // </summary>
		public const ulong SanitizerCidEmbedsOnly = (1<<2);
		
		// <summary>
        // Flag for sanitizer: Drop non-CSS presentational HTML elements and
        // attributes, such as <font>, <center> and bgcolor="".
        // </summary>
		public const ulong SanitizerDropNonCSSPresentation = (1<<3);
		
		// <summary>
        // Flag for sanitizer: Drop forms and form controls (excluding
        // fieldset/legend).
        // </summary>
		public const ulong SanitizerDropForms = (1<<4);
		
		// <summary>
        // Flag for sanitizer: Drop <img>, <video>, <audio> and <source> and flatten
        // out SVG.
        // </summary>
		public const ulong SanitizerDropMedia = (1<<5);
	}
}
